package com.sq.partner.manager.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.IGatewayVatDao;
import com.sq.partner.manager.dao.impl.BaseDaoImpl;
import com.sq.partner.manager.mybatis.model.GatewayVatRate;
import com.sq.partner.manager.mybatis.model.VatFromDto;
import com.sq.partner.manager.service.IGatewayClearCacheManager;
import com.sq.partner.manager.service.IGatewayVatService;
import com.sq.partner.manager.util.Page;


/**
 * 
 * @author dinghao
 *
 */
@Service
public class GatewayVatServiceImpl extends BaseDaoImpl implements IGatewayVatService {
	@Resource
	private IGatewayVatDao vatDao;
	@Resource
	IGatewayClearCacheManager gatewayClearCacheManager;
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	@Override
	public Map <String ,VatFromDto> queryFromVat() {
		// TODO Auto-generated method stub
		return vatDao.queryFromVat();
	}
	@Override
	public List<Object[]> queryListObjectsFromVat() throws Exception {
		// TODO Auto-generated method stub
		return vatDao.queryListObjectsFromVat();
	}
	@Override
	public boolean addVat(VatFromDto vatFromDto) throws Exception {
		// TODO Auto-generated method stub
		GatewayVatRate gatewayVatRate = new GatewayVatRate();
		gatewayVatRate.setCoreRiskCode(vatFromDto.getCoreRiskCode());
		gatewayVatRate.setDeptCode(vatFromDto.getDeptCode());
		gatewayVatRate.setVatRiskCode(vatFromDto.getVatRiskCode());
		gatewayVatRate.setUpdateTime(sdf.format(new Date()));
		gatewayVatRate.setStatus("1");
		gatewayVatRate.setVatRate(vatFromDto.getVatRate());
		return vatDao.addVat(gatewayVatRate);
	}

	@Override
	public boolean updateVat(VatFromDto vatFromDto) throws Exception {
		// TODO Auto-generated method stub
		GatewayVatRate gatewayVatRate = new GatewayVatRate();
		gatewayVatRate.setCoreRiskCode(vatFromDto.getCoreRiskCode());
		gatewayVatRate.setDeptCode(vatFromDto.getDeptCode());
		gatewayVatRate.setVatRiskCode(vatFromDto.getVatRiskCode());
		gatewayVatRate.setUpdateTime(sdf.format(new Date()));
		gatewayVatRate.setStatus("1");
		gatewayVatRate.setVatRate(vatFromDto.getVatRate());
		return vatDao.updateVat(gatewayVatRate);
	}

	@Override
	public GatewayVatRate queryToVat(VatFromDto vatFromDto) throws Exception {
		// TODO Auto-generated method stub
		GatewayVatRate gatewayVatRate = new GatewayVatRate();
		gatewayVatRate.setCoreRiskCode(vatFromDto.getCoreRiskCode());
		gatewayVatRate.setDeptCode(vatFromDto.getDeptCode());
		return vatDao.queryToVat(gatewayVatRate);
	}

	@Override
	public Page queryPage(Page page)
			throws Exception {
		// TODO Auto-generated method stub
	
		return vatDao.queryPage(page);
	}

	@Override
	public VatFromDto querySingleVat(GatewayVatRate gatewayVatRate) throws Exception {
		// TODO Auto-generated method stub
		return vatDao.querySingleFromVat( gatewayVatRate);
	}
	@Override
	public boolean BatchInsertVatRate(List<Object[]> params) throws Exception {
		// TODO Auto-generated method stub
		return vatDao.BatchInsertVatRate(params);
	}
	@Override
	public boolean DelOldVatAndCopyNewVatRate() throws Exception {
		// TODO Auto-generated method stub
		return vatDao.DelOldVatAndCopyNewVatRate();
	}




	
}
